import com.sun.org.apache.xpath.internal.operations.Bool;

public class Linearlist {
    public int maxSize = 100000;
    //存放数据
    public String sname[] = new String[maxSize];
    //记录当前线性表长度
    public int length;

    public void InitList() {
        this.length = 5;
    }

    //取元素
    public String getItem(Linearlist l, int i) {

        return l.sname[i];
    }

    //插入
    public boolean Listinsert(Linearlist l, int i, String s) {
        //判断线性表是否满
        if (l.length == maxSize) {
            System.out.println("超出线性表大小");
            return false;
        }
        if (i < 1 || i > l.length - 1)   //判断插入位置是否合理
        {
            System.out.println("插入位置错误");
            return false;
        }

        for (int k = l.length - 1; k >= i - 1; k--)
            l.sname[k + 1] = l.sname[k];
        l.sname[i - 1] = s;
        l.length++;
        System.out.println("插入成功");
        return true;
    }

    //删除元素
    public boolean Listdelete(Linearlist l, int i, String s) {
        //判断线性表是否满
        if (l.length == 0) {
            System.out.println("线性表已空");
            return false;
        }
        if (i < 1 || i > l.length - 1)   //判断删除位置是否合理
        {
            System.out.println("删除位置错误");
            return false;
        }
        s = l.sname[i - 1];

        for (int k = i; k < l.length; k++)
            l.sname[k - 1] = l.sname[k];

        l.length--;
        System.out.println("删除成功");
        return true;
    }


    public boolean ListEmpty(Linearlist l) {
        return l.length == 0;
    }


    public static void main(String[] args) {
        String names = "faf fsaf asfsa fsaf a ffdsfd";
        String s[] = names.split(" ");
        Linearlist l = new Linearlist();
        l.InitList();
        int index = 1;
        for (String i : s) {
            l.Listinsert(l, index++, i);
        }

        System.out.println(s[0]);
    }
}
